﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ObjectSweptVolume.CObjectSweptVolumeCmd
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;
using System.Windows;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.ObjectSweptVolume;

public class CObjectSweptVolumeCmd : TxButtonCommand
{
  private CObjectSweptVolumeCmd.CObjectSweptVolumeCmdEnabler m_enabler;
  private CObjectSweptVolumeDlg _window;

  public CObjectSweptVolumeCmd()
  {
    this.m_enabler = new CObjectSweptVolumeCmd.CObjectSweptVolumeCmdEnabler();
  }

  public virtual void Execute(object cmdParams)
  {
    if (this._window != null)
      ((Window) this._window).Close();
    this._window = new CObjectSweptVolumeDlg();
    ((Window) this._window).Closed += new EventHandler(this._window_Closed);
    ((Window) this._window).Show();
  }

  public virtual string Category => StringTable.OSV_CATEGORY;

  public virtual string Name => StringTable.OSV_NAME;

  public virtual string Tooltip => StringTable.OSV_TOOLTIP;

  public virtual string Description => StringTable.OSV_DESCRIPTION;

  public virtual string Bitmap => "ObjectSweptVolume.Resources.ObjSweptVolume.bmp";

  public virtual string LargeBitmap => "ObjectSweptVolume.Resources.ObjSweptVolume_LARGE.png";

  public virtual ITxCommandEnabler CommandEnabler => (ITxCommandEnabler) this.m_enabler;

  public virtual ITxImage Image => (ITxImage) TxImageManager.GetImageByKey("ObjectSweptVolume");

  public virtual bool Licensed => TxCommandLicenser.SweptVolumeLicense;

  private void _window_Closed(object sender, EventArgs e)
  {
    ((Window) (sender as CObjectSweptVolumeDlg)).Closed -= new EventHandler(this._window_Closed);
    if (this._window != sender)
      return;
    this._window = (CObjectSweptVolumeDlg) null;
  }

  private class CObjectSweptVolumeCmdEnabler : ITxCommandEnabler
  {
    public bool Enable
    {
      get => TxApplication.ActiveDocument.PlatformGlobalServicesProvider.IsDocumentLoaded();
    }
  }
}
